/* 红外温度分析系统 Web版 - 自定义样式 */

/* ==================== CSS变量定义 ==================== */
:root {
    /* 主色调 */
    --brand-green: #059669;      /* emerald-600 */
    --brand-teal: #0d9488;       /* teal-600 */
    --brand-green-hover: #047857; /* emerald-700 */
    --brand-teal-hover: #0f766e;  /* teal-700 */
    
    /* 渐变色彩 */
    --gradient-primary: linear-gradient(135deg, var(--brand-green), var(--brand-teal));
    --gradient-primary-hover: linear-gradient(135deg, var(--brand-green-hover), var(--brand-teal-hover));
    --gradient-light: linear-gradient(135deg, #ecfdf5, #f0fdfa); /* emerald-50 to teal-50 */
    
    /* 功能色彩 */
    --success-color: #10b981;    /* emerald-500 */
    --warning-color: #f59e0b;    /* amber-500 */
    --error-color: #ef4444;      /* red-500 */
    --info-color: #3b82f6;       /* blue-500 */
    
    /* 灰度色彩 */
    --gray-900: #111827;
    --gray-700: #374151;
    --gray-600: #6b7280;
    --gray-500: #9ca3af;
    --gray-200: #e5e7eb;
    --gray-50: #f9fafb;
    
    /* 阴影层级 */
    --shadow-card: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

/* ==================== 全局样式 ==================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--gray-50);
}

/* ==================== 上传区域样式 ==================== */
#upload-area {
    transition: all 0.3s ease;
    background: linear-gradient(135deg, transparent, rgba(16, 185, 129, 0.05));
}

#upload-area:hover {
    border-color: var(--brand-green);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(13, 148, 136, 0.05));
    transform: translateY(-2px);
}

#upload-area.drag-over {
    border-color: var(--brand-green);
    background: var(--gradient-light);
    transform: scale(1.02);
}

/* ==================== 画布容器样式 ==================== */
#canvas-container {
    position: relative;
    background: #fafafa;
    border: 2px solid var(--gray-200);
    min-height: 500px;
    max-height: 70vh;
    overflow: hidden;
}

#image-canvas, #overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 0;
}

#overlay-canvas {
    pointer-events: none;
    z-index: 10;
}

/* 区域选择样式 */
.selection-box {
    border: 2px solid var(--brand-green);
    background: rgba(5, 150, 105, 0.1);
    border-radius: 4px;
}

.region-marker {
    border: 2px solid var(--brand-teal);
    background: rgba(13, 148, 136, 0.15);
    border-radius: 4px;
}

/* ==================== 按钮增强样式 ==================== */
.btn-primary {
    background: var(--gradient-primary);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--gradient-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--gray-500);
    transform: none;
    box-shadow: none;
}

/* ==================== 卡片样式增强 ==================== */
.card-enhanced {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.card-enhanced:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

/* ==================== 结果卡片样式 ==================== */
.result-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--gray-200);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
}

.result-card:hover::before {
    opacity: 1;
}

.result-card .region-id {
    background: var(--gradient-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 12px;
}

.temperature-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 8px 0;
}

.temp-min { color: #3b82f6; }  /* blue-500 */
.temp-max { color: #ef4444; }  /* red-500 */
.temp-avg { color: var(--brand-green); }

/* ==================== 区域列表项样式 ==================== */
.region-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
    position: relative;
}

.region-item:hover {
    border-color: var(--brand-green);
    background: rgba(16, 185, 129, 0.02);
    transform: translateX(4px);
}

.region-item .remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.region-item .remove-btn:hover {
    transform: scale(1.1);
    background: #dc2626; /* red-600 */
}

/* ==================== 加载动画 ==================== */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: loading-bounce 1.5s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== 状态指示器 ==================== */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-indicator.disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.status-indicator.loading {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

.status-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-indicator.loading::before {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* ==================== 响应式优化 ==================== */
@media (max-width: 768px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    #canvas-container {
        min-height: 300px;
        max-height: 50vh;
    }
    
    .result-card {
        padding: 16px;
    }
    
    /* 移动端调整网格 */
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ==================== 自定义滚动条 ==================== */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: var(--brand-green) var(--gray-200);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--gray-200);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--brand-green);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--brand-green-hover);
}

/* ==================== 特殊效果 ==================== */
.glass-effect {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 温度值颜色编码 */
.temp-cold { color: #3b82f6; }      /* 冷色调 - 蓝色 */
.temp-normal { color: var(--brand-green); }  /* 正常 - 绿色 */
.temp-hot { color: #f59e0b; }       /* 温暖 - 黄色 */
.temp-very-hot { color: #ef4444; }  /* 高温 - 红色 */

/* ==================== 工具提示 ==================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ==================== 动画增强 ==================== */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== 画布交互增强 ==================== */
#canvas-container.selecting {
    cursor: crosshair;
}

#canvas-container.selecting #image-canvas {
    cursor: crosshair;
}

/* 选择框样式 */
.selecting-box {
    border: 2px dashed var(--brand-green);
    background: rgba(5, 150, 105, 0.1);
    position: absolute;
    pointer-events: none;
    z-index: 5;
    border-radius: 4px;
}

/* 区域标记样式 */
.region-overlay {
    border: 2px solid var(--brand-teal);
    background: rgba(13, 148, 136, 0.15);
    position: absolute;
    pointer-events: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-teal);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* ==================== 状态样式 ==================== */
.processing {
    position: relative;
    overflow: hidden;
}

.processing::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ==================== 美化滚动条 ==================== */
#regions-list,
#results-container {
    scrollbar-width: thin;
    scrollbar-color: var(--brand-green) var(--gray-200);
}

#regions-list::-webkit-scrollbar,
#results-container::-webkit-scrollbar {
    width: 6px;
}

#regions-list::-webkit-scrollbar-track,
#results-container::-webkit-scrollbar-track {
    background: var(--gray-200);
    border-radius: 3px;
}

#regions-list::-webkit-scrollbar-thumb,
#results-container::-webkit-scrollbar-thumb {
    background: var(--brand-green);
    border-radius: 3px;
}

#regions-list::-webkit-scrollbar-thumb:hover,
#results-container::-webkit-scrollbar-thumb:hover {
    background: var(--brand-green-hover);
}

/* ==================== 特殊图标样式 ==================== */
.icon-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 模态框增强 ==================== */
.modal-backdrop {
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    animation: scaleIn 0.3s ease-out;
    box-shadow: var(--shadow-modal);
}

/* ==================== 辅助类 ==================== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
                var(--gradient-primary) border-box;
}

.shadow-brand {
    box-shadow: 0 10px 25px -3px rgba(5, 150, 105, 0.2), 
                0 4px 6px -2px rgba(5, 150, 105, 0.1);
}

/* ==================== 打印样式 ==================== */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .result-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}